package cz.najman.emdroid.connection;

import java.io.IOException;

import org.apache.http.client.ClientProtocolException;

import cz.najman.emdroid.content.ContentProducer;

import android.net.Uri;

/**
 * Interface used to specify contract for connection methods.
 * Follows the CRUD pattern.
 */
public interface ConnectionMethod {	
	
	public static final int METHOD_GET = 1;
	public static final int METHOD_POST = 2;
	public static final int METHOD_UPDATE = 3;
	public static final int METHOD_DELETE = 4;
	public static final int METHOD_NONE = -1;
	
	public static final int RESPONSE_CODE_NONE = -1;
	public static final int RESPONSE_CODE_OK = 200; 
	public static final int RESPONSE_CODE_CREATED = 201;
	public static final int RESPONSE_CODE_ACCEPTED = 202;
	public static final int RESPONSE_CODE_NOTE_MODIFIED = 304;
	public static final int RESPONSE_CODE_NOT_FOUND = 404;
	public static final int RESPONSE_CODE_INTERNAL_ERROR = 500;
	public static final int RESPONSE_CODE_REQUEST_TIMEOUT = 408;
	
	public static final int RESPONSE_CODE_CONNECTION_REFUSED = 600;
	public static final int RESPONSE_CODE_NOT_SUCCESSFULL = 601;
	
	/**
	 * 
	 * @param uri
	 * @param responseHandler
	 * @param contentProducer
	 * @return
	 * @throws IOException 
	 * @throws ClientProtocolException 
	 */
	public int create(Uri uri, ResponseHandler responseHandler, ContentProducer contentProducer) throws ClientProtocolException, IOException;
	
	/**
	 * 
	 * @param uri
	 * @param responseHandler
	 * @return
	 * @throws IOException 
	 * @throws ClientProtocolException 
	 */
	public int retrieve(Uri uri, ResponseHandler responseHandler) throws ClientProtocolException, IOException;
	
	/**
	 * 
	 * @param uri
	 * @param responseHandler
	 * @param contentProducer
	 * @return
	 */
	public int update(Uri uri, ResponseHandler responseHandler, ContentProducer contentProducer);	
	
	/**
	 * 
	 * @param uri
	 * @param responseHandler
	 * @return
	 */
	public int delete(Uri uri, ResponseHandler responseHandler);
	
}
